/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

.clearfix() {
  &:after {
    clear: both;
  }

  &:after,
  &:before {
    content: '';
    display: table;
  }
}

.center-block() {
  margin-left: auto;
  margin-right: auto;
  display: block;
}

.tab-focus() {
  outline-offset: -2px;
  outline: thin dotted;
  outline: 5px auto -webkit-focus-ring-color;
}

.square(@size) {
  .size(@size; @size);
}

.size(@width; @height) {
  width: @width;
  height: @height;
}

.placeholder(@color: #999) {
  &:-moz-placeholder {
    color: @color;
  }

  &::-moz-placeholder {
    color: @color;
    opacity: 1;
  }

  &:-ms-input-placeholder {
    color: @color;
  }

  &::-webkit-input-placeholder {
    color: @color;
  }

  &::-ms-input-placeholder {
    color: @color;
  }

  &::placeholder {
    color: @color;
  }
}

.text-overflow() {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.hide-text() {
  font: ~'0/0' a;
  border: 0;
  background-color: transparent;
  text-shadow: none;
  color: transparent;
}

.text-hide() {
  .hide-text();
}

.border-top-radius(@radius) {
  border-top-left-radius: @radius;
  border-top-right-radius: @radius;
}

.border-right-radius(@radius) {
  border-top-right-radius: @radius;
  border-bottom-right-radius: @radius;
}

.border-bottom-radius(@radius) {
  border-bottom-left-radius: @radius;
  border-bottom-right-radius: @radius;
}

.border-left-radius(@radius) {
  border-top-left-radius: @radius;
  border-bottom-left-radius: @radius;
}

.box-shadow(@shadow) {
  -webkit-box-shadow: @shadow;
  box-shadow: @shadow;
}

.transition(@transition) {
  transition: @transition;
  -webkit-transition: @transition;
}

.transition-property(@transition-property) {
  transition-property: @transition-property;
  -webkit-transition-property: @transition-property;
}

.transition-delay(@transition-delay) {
  transition-delay: @transition-delay;
  -webkit-transition-delay: @transition-delay;
}

.transition-duration(@transition-duration) {
  transition-duration: @transition-duration;
  -webkit-transition-duration: @transition-duration;
}

.transition-transform(@transition) {
  transition: transform @transition;
  -o-transition: -o-transform @transition;
  -moz-transition: -moz-transform @transition;
  -webkit-transition: -webkit-transform @transition;
}

.rotate(@degrees) {
  transform: rotate(@degrees);
  -ms-transform: rotate(@degrees);
  -webkit-transform: rotate(@degrees);
}

.scale(@ratio) {
  transform: scale(@ratio);
  -ms-transform: scale(@ratio);
  -webkit-transform: scale(@ratio);
}

.translate(@x; @y) {
  transform: translate(@x, @y);
  -ms-transform: translate(@x, @y);
  -webkit-transform: translate(@x, @y);
}

.skew(@x; @y) {
  -webkit-transform: skew(@x, @y);
  -ms-transform: skewX(@x) skewY(@y);
  transform: skew(@x, @y);
}

.translate3d(@x; @y; @z) {
  transform: translate3d(@x, @y, @z);
  -webkit-transform: translate3d(@x, @y, @z);
}

.rotateX(@degrees) {
  transform: rotateX(@degrees);
  -ms-transform: rotateX(@degrees);
  -webkit-transform: rotateX(@degrees);
}

.rotateY(@degrees) {
  transform: rotateY(@degrees);
  -ms-transform: rotateY(@degrees);
  -webkit-transform: rotateY(@degrees);
}

.perspective(@perspective) {
  perspective: @perspective;
  -moz-perspective: @perspective;
  -webkit-perspective: @perspective;
}

.perspective-origin(@perspective) {
  perspective-origin: @perspective;
  -moz-perspective-origin: @perspective;
  -webkit-perspective-origin: @perspective;
}

.transform-origin(@origin) {
  -webkit-transform-origin: @origin;
  -moz-transform-origin: @origin;
  transform-origin: @origin;
}

.animation(@animation) {
  -webkit-animation: @animation;
  animation: @animation;
}

.backface-visibility(@visibility) {
  -webkit-backface-visibility: @visibility;
  -moz-backface-visibility: @visibility;
  backface-visibility: @visibility;
}

.box-sizing(@boxmodel) {
  -webkit-box-sizing: @boxmodel;
  -moz-box-sizing: @boxmodel;
  box-sizing: @boxmodel;
}

.user-select(@select) {
  user-select: @select;
  -moz-user-select: @select;
  -webkit-user-select: @select;
  -o-user-select: @select;
  -ms-user-select: @select;
}

.resizable(@direction) {
  resize: @direction;
  overflow: auto;
}

.content-columns(@column-count; @column-gap: @grid-gutter-width) {
  column-gap: @column-gap;
  column-count: @column-count;
  -webkit-column-count: @column-count;
  -moz-column-count: @column-count;
  -moz-column-gap: @column-gap;
  -webkit-column-gap: @column-gap;
}

.hyphens(@mode: auto) {
  hyphens: @mode;
  -o-hyphens: @mode;
  -ms-hyphens: @mode;
  -moz-hyphens: @mode;
  -webkit-hyphens: @mode;
  word-wrap: break-word;
}

.opacity(@opacity) {
  @opacity-ie: (@opacity * 100);
  opacity: @opacity;
  filter: ~'alpha(opacity=@{opacity-ie})';
}

#gradient {
  .horizontal(@start-color: #555; @end-color: #333; @start-percent: 0%; @end-percent: 100%) {
    background-image: -webkit-linear-gradient(
      left,
      color-stop(@start-color @start-percent),
      color-stop(@end-color @end-percent)
    );
    background-image: linear-gradient(to right, @start-color @start-percent, @end-color @end-percent);
    background-repeat: repeat-x;
    filter: e(
      %(
        "progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",
        argb(@start-color),
        argb(@end-color)
      )
    );
  }

  .vertical(@start-color: #555; @end-color: #333; @start-percent: 0%; @end-percent: 100%) {
    background-image: -webkit-linear-gradient(top, @start-color @start-percent, @end-color @end-percent);
    background-image: linear-gradient(to bottom, @start-color @start-percent, @end-color @end-percent);
    background-repeat: repeat-x;
    filter: e(
      %(
        "progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",
        argb(@start-color),
        argb(@end-color)
      )
    );
  }

  .directional(@start-color: #555; @end-color: #333; @deg: 45deg) {
    background-repeat: repeat-x;
    background-image: -webkit-linear-gradient(@deg, @start-color, @end-color);
    background-image: linear-gradient(@deg, @start-color, @end-color);
  }

  .horizontal-three-colors(@start-color: #00b3ee; @mid-color: #7a43b6; @color-stop: 50%; @end-color: #c3325f) {
    background-image: -webkit-linear-gradient(left, @start-color, @mid-color @color-stop, @end-color);
    background-image: linear-gradient(to right, @start-color, @mid-color @color-stop, @end-color);
    background-repeat: no-repeat;
    filter: e(
      %(
        "progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",
        argb(@start-color),
        argb(@end-color)
      )
    );
  }

  .vertical-three-colors(@start-color: #00b3ee; @mid-color: #7a43b6; @color-stop: 50%; @end-color: #c3325f) {
    background-image: -webkit-linear-gradient(@start-color, @mid-color @color-stop, @end-color);
    background-image: linear-gradient(@start-color, @mid-color @color-stop, @end-color);
    background-repeat: no-repeat;
    filter: e(
      %(
        "progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",
        argb(@start-color),
        argb(@end-color)
      )
    );
  }

  .radial(@inner-color: #555; @outer-color: #333) {
    background-image: -webkit-radial-gradient(circle, @inner-color, @outer-color);
    background-image: radial-gradient(circle, @inner-color, @outer-color);
    background-repeat: no-repeat;
  }

  .striped(@color: rgba(255, 255, 255, 0.15); @angle: 45deg) {
    background-image: -webkit-linear-gradient(
      @angle,
      @color 25%,
      transparent 25%,
      transparent 50%,
      @color 50%,
      @color 75%,
      transparent 75%,
      transparent
    );
    background-image: linear-gradient(
      @angle,
      @color 25%,
      transparent 25%,
      transparent 50%,
      @color 50%,
      @color 75%,
      transparent 75%,
      transparent
    );
  }
}

.reset-filter() {
  filter: e(%('progid:DXImageTransform.Microsoft.gradient(enabled = false)'));
}

.img-retina(@file-1x; @file-2x; @width-1x; @height-1x) {
  background-image: url('@{file-1x}');

  @media only screen and (-webkit-min-device-pixel-ratio: 2),
    only screen and (min--moz-device-pixel-ratio: 2),
    only screen and (-o-min-device-pixel-ratio: 2/1),
    only screen and (min-device-pixel-ratio: 2),
    only screen and (min-resolution: 192dpi),
    only screen and (min-resolution: 2dppx) {
    background-image: url('@{file-2x}');
    background-size: @width-1x @height-1x;
  }
}

.img-responsive(@display: block; ) {
  display: @display;
  max-width: 100%;
  height: auto;
}

.nav-divider(@color: #e5e5e5) {
  height: 1px;
  margin: ((@line-height-computed / 2) - 1) 0;
  overflow: hidden;
  background-color: @color;
}

.panel-variant( @heading-text-color; @heading-bg-color; @heading-border;@border;) {
  border-color: @border;

  & > .panel-heading {
    border-color: @heading-border;
    background-color: @heading-bg-color;
    color: @heading-text-color;

    + .panel-collapse .panel-body {
      border-top-color: @border;
    }
  }

  & > .panel-footer {
    + .panel-collapse .panel-body {
      border-bottom-color: @border;
    }
  }
}

.table-row-variant(@state; @background) {
  .table {
    > tfoot,
    > tbody,
    > thead {
      > .@{state} > th,
      > .@{state} > td,
      > tr > .@{state} {
        background-color: @background;
      }
    }
  }

  .table-hover > tbody {
    > .@{state}:hover > th,
    > .@{state}:hover > td,
    > tr > .@{state}:hover {
      background-color: darken(@background, 5%);
    }
  }
}

.pagination-size(@padding-vertical; @padding-horizontal; @font-size; @border-radius) {
  > li {
    > span,
    > a {
      font-size: @font-size;
      padding: @padding-vertical @padding-horizontal;
    }

    &:first-child {
      > span,
      > a {
        .border-left-radius(@border-radius);
      }
    }

    &:last-child {
      > span,
      > a {
        .border-right-radius(@border-radius);
      }
    }
  }
}

.label-variant(@color) {
  background-color: @color;

  &[href] {
    &:focus,
    &:hover {
      background-color: darken(@color, 10%);
    }
  }
}

.navbar-vertical-align(@element-height) {
  margin-top: ((@navbar-height - @element-height) / 2);
  margin-bottom: ((@navbar-height - @element-height) / 2);
}

// Progress bars
.progress-bar-variant(@color) {
  background-color: @color;

  .progress-striped & {
    #gradient > .striped();
  }
}

.responsive-visibility() {
  display: block !important;

  table& {
    display: table;
  }

  tr& {
    display: table-row !important;
  }

  th&,
  td& {
    display: table-cell !important;
  }
}

.responsive-invisibility() {
  &,
  tr&,
  th&,
  td& {
    display: none !important;
  }
}

.container-fixed() {
  margin-left: auto;
  margin-right: auto;
  padding-right: (@grid-gutter-width / 2);
  padding-left: (@grid-gutter-width / 2);
  .clearfix();
}

.make-row(@gutter: @grid-gutter-width) {
  margin-left: (@gutter / -2);
  margin-right: (@gutter / -2);
  .clearfix();
}

.make-xs-column(@columns; @gutter: @grid-gutter-width) {
  float: left;
  position: relative;
  min-height: 1px;
  width: percentage((@columns / @grid-columns));
  padding-right: (@gutter / 2);
  padding-left: (@gutter / 2);
  box-sizing: border-box;
}

.make-sm-column(@columns; @gutter: @grid-gutter-width) {
  position: relative;
  min-height: 1px;
  padding-left: (@gutter / 2);
  padding-right: (@gutter / 2);
  box-sizing: border-box;

  @media (min-width: @screen-sm-min) {
    float: left;
    width: percentage((@columns / @grid-columns));
  }
}

.make-sm-column-push(@columns) {
  @media (min-width: @screen-sm-min) {
    left: percentage((@columns / @grid-columns));
  }
}

.make-sm-column-offset(@columns) {
  @media (min-width: @screen-sm-min) {
    margin-left: percentage((@columns / @grid-columns));
  }
}

.make-sm-column-pull(@columns) {
  @media (min-width: @screen-sm-min) {
    right: percentage((@columns / @grid-columns));
  }
}

.make-md-column(@columns; @gutter: @grid-gutter-width) {
  position: relative;
  min-height: 1px;
  padding-left: (@gutter / 2);
  padding-right: (@gutter / 2);
  box-sizing: border-box;

  @media (min-width: @screen-md-min) {
    width: percentage((@columns / @grid-columns));
    float: left;
  }
}

.make-md-column-push(@columns) {
  @media (min-width: @screen-md) {
    left: percentage((@columns / @grid-columns));
  }
}

.make-md-column-offset(@columns) {
  @media (min-width: @screen-md-min) {
    margin-left: percentage((@columns / @grid-columns));
  }
}

.make-md-column-pull(@columns) {
  @media (min-width: @screen-md-min) {
    right: percentage((@columns / @grid-columns));
  }
}

.make-lg-column(@columns; @gutter: @grid-gutter-width) {
  position: relative;
  min-height: 1px;
  padding-left: (@gutter / 2);
  padding-right: (@gutter / 2);
  box-sizing: border-box;

  @media (min-width: @screen-lg-min) {
    width: percentage((@columns / @grid-columns));
    float: left;
  }
}

.make-lg-column-pull(@columns) {
  @media (min-width: @screen-lg-min) {
    right: percentage((@columns / @grid-columns));
  }
}

.make-lg-column-push(@columns) {
  @media (min-width: @screen-lg-min) {
    left: percentage((@columns / @grid-columns));
  }
}

.make-lg-column-offset(@columns) {
  @media (min-width: @screen-lg-min) {
    margin-left: percentage((@columns / @grid-columns));
  }
}

.make-xl-column(@columns; @gutter: @grid-gutter-width) {
  position: relative;
  min-height: 1px;
  padding-left: (@gutter / 2);
  padding-right: (@gutter / 2);
  box-sizing: border-box;

  @media (min-width: @screen-xl-min) {
    float: left;
    width: percentage((@columns / @grid-columns));
  }
}

.make-xl-column-offset(@columns) {
  @media (min-width: @screen-xl-min) {
    margin-left: percentage((@columns / @grid-columns));
  }
}

.make-xl-column-push(@columns) {
  @media (min-width: @screen-xl-min) {
    left: percentage((@columns / @grid-columns));
  }
}

.make-xl-column-pull(@columns) {
  @media (min-width: @screen-xl-min) {
    right: percentage((@columns / @grid-columns));
  }
}

.make-grid-columns() {
  .col(@index) when (@index =1) {
    @item: ~'.col-xs-@{index}, .col-sm-@{index}, .col-md-@{index}, .col-lg-@{index}, .col-xl-@{index}';
    .col(@index + 1, @item);
  }

  .col(@index, @list) when (@index =< @grid-columns) {
    @item: ~'.col-xs-@{index}, .col-sm-@{index}, .col-md-@{index}, .col-lg-@{index}, .col-xl-@{index}';
    .col(@index + 1, ~'@{list}, @{item}');
  }

  .col(@index, @list) when (@index > @grid-columns) {
    @{list} {
      position: relative;
      min-height: 1px;
      padding-left: (@grid-gutter-width / 2);
      padding-right: (@grid-gutter-width / 2);
      box-sizing: border-box;
    }
  }

  .col(1);
}

.make-grid-columns-float(@class) {
  .col(@index) when (@index =1) {
    @item: ~'.col-@{class}-@{index}';
    .col(@index + 1, @item);
  }

  .col(@index, @list) when (@index =< @grid-columns) {
    @item: ~'.col-@{class}-@{index}';
    .col(@index + 1, ~'@{list}, @{item}');
  }

  .col(@index, @list) when (@index > @grid-columns) {
    @{list} {
      float: left;
    }
  }

  .col(1);
}

.calc-grid(@index, @class, @type) when (@type =width) and (@index > 0) {
  .calc-grid(@index, @class, @type) when (@type =push) {
    .col-@{class}-push-@{index} {
      left: percentage((@index / @grid-columns));
    }
  }

  .col-@{class}-@{index} {
    width: percentage((@index / @grid-columns));
  }
}

.calc-grid(@index, @class, @type) when (@type =offset) {
  .col-@{class}-offset-@{index} {
    margin-left: percentage((@index / @grid-columns));
  }
}

.calc-grid(@index, @class, @type) when (@type =pull) {
  .col-@{class}-pull-@{index} {
    right: percentage((@index / @grid-columns));
  }
}

.make-grid(@index, @class, @type) when (@index >=0) {
  .make-grid(@index - 1, @class, @type);
  .calc-grid(@index, @class, @type);
}

.form-control-validation(@text-color: #555; @border-color: #ccc; @background-color: #f5f5f5) {
  .radio-inline,
  .checkbox,
  .radio,
  .control-label,
  .checkbox-inline,
  .help-block {
    color: @text-color;
  }

  .form-control {
    border-color: @border-color;
    .box-shadow(
      inset 0 1px 1px rgba(0, 0, 0, 0.075)
    );

    &:focus {
      border-color: darken(@border-color, 10%);
      @shadow:
        inset 0 1px 1px rgba(0, 0, 0, 0.075),
        0 0 6px lighten(@border-color, 20%);
      .box-shadow(@shadow);
    }
  }

  .input-group-addon {
    color: @text-color;
    border-color: @border-color;
    background-color: @background-color;
  }
}

.form-control-focus(@color: @input-border-focus) {
  @color-rgba: rgba(red(@color), green(@color), blue(@color), 0.6);

  &:focus {
    border-color: @color;
    outline: 0;
    .box-shadow(~'inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px @{color-rgba}');
  }
}

.input-size(@input-height; @padding-vertical; @padding-horizontal; @font-size; @line-height; @border-radius) {
  border-radius: @border-radius;
  line-height: @line-height;
  font-size: @font-size;
  padding: @padding-vertical @padding-horizontal;
  height: @input-height;

  textarea& {
    height: auto;
  }

  select& {
    line-height: @input-height;
    height: @input-height;
  }
}
